<%@ include file="shared_header.jsp" %>
<%@ page import="vrp.Distance" %>

<%
	SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd");
	PersistenceManager pm = PMF.get().getPersistenceManager();
	String query = "";
	
    List<Distance> distances;	
    query = "select from " + Distance.class.getName();
    distances = (List<Distance>) pm.newQuery(query).execute();

%>
	<div style="padding: 0px 10px;">
		<h2>List of Distances</h2>
		<table style="width: 100%;">
<%
	
    if (distances.isEmpty()) {
%>
			<tr><td>There is no distance in the database.</td></tr>
<%
    } else {
%>
			<tr>
				<th>From</th>
				<th>To</th>
				<th>Length</th>
			</tr>
<%
        for (Distance p : distances) {
%>
			<tr>
				<td style="text-align: center;"><%= p.getFrom() %></td>
				<td style="text-align: center;"><%= p.getTo() %></td>
				<td style="text-align: center;"><%= p.getLength() %></td>
			</tr>
<%
        }
    }
%>
			
		</table>
	</div>
	
<%
    pm.close();
%>

<%@ include file="shared_footer.jsp" %>